package com.google.coffeeshop.dao.impl;

import com.google.coffeeshop.dao.ProductPriceDAO;
import com.google.coffeeshop.entity.ProductSellingPriceDTO;
import com.googlecode.genericdao.search.Search;


public class ProductPriceDAOImpl extends AbstractBaseDAOImpl<ProductSellingPriceDTO, Long> implements ProductPriceDAO {

	@Override
	public ProductSellingPriceDTO findLastestPriceByProductId(long productId) {
		Search search = new Search(ProductSellingPriceDTO.class);
		search.setFirstResult(0);
		search.setMaxResults(1);
		search.addFilterEqual("product.id", productId);
		search.addSortAsc("applyDate");
		return this.searchUnique(search);
	}

}
